/**
 * 获取当前时间(格式 YYYY-MM-dd HH:mm:ss)
 * @returns
 */
function NowTime(){
	var times = null
	let year = new Date().getFullYear();
	let month = new Date().getMonth() + 1;
	let days = new Date().getDate();
	let hour = new Date().getHours()
	let minutes = new Date().getMinutes()
	let second = new Date().getSeconds()
	if (month < 10) { month = '0' + month }
	if (days < 10) { days = '0' + days }
	if (hour < 10) { hour = '0' + hour }
	if (minutes < 10) {minutes = '0' + minutes }
	if (second < 10) { second = '0' + second }
	return times = year + '-' + month + '-' + days + ' ' + hour + ':' + minutes + ':' + second
}

/**
 * 指定日期转换格式 YYYY-MM-dd HH:mm:ss)
 * @param {String} Arg_Datetime 指定日期
 * @returns
 */
function StringTime(Arg_Datetime){
	var times = null
	let year = new Date(Arg_Datetime).getFullYear();
	let month = new Date(Arg_Datetime).getMonth() + 1;
	let days = new Date(Arg_Datetime).getDate();
	let hour = new Date(Arg_Datetime).getHours()
	let minutes = new Date(Arg_Datetime).getMinutes()
	let second = new Date(Arg_Datetime).getSeconds()
	if (month < 10) { month = '0' + month }
	if (days < 10) { days = '0' + days }
	if (hour < 10) { hour = '0' + hour }
	if (minutes < 10) {minutes = '0' + minutes }
	if (second < 10) { second = '0' + second }
	return times = year + '-' + month + '-' + days + ' ' + hour + ':' + minutes + ':' + second
}

/**
 * 获取当前时间戳，单位秒
 * @returns
 */
function getCurrentTimestamp(){
	return Math.floor(Date.now() / 1000);
}

module.exports = {
	NowTime,
	StringTime,
	getCurrentTimestamp
}